﻿@model IEnumerable<DLM.Domain.DTO.SalutationDTO>
@using DLM.Domain.Model;
@using Webdiyer.WebControls.Mvc;
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("ul.clearfix li").mouseover(function () {

            $(this).addClass("hover");
        });
        $("ul.clearfix li").mouseout(function () {

            $(this).removeClass("hover");
        });
        $("a").css("cursor", "pointer");
    });


    function confirmGreet(id) {
        var request = $.ajax({
            type: "POST",
            url: "/Friend/Confirm/",
            data: { id: id },
            success: function (data, textStatus) {
                //$(".ajax.ajaxResult").html("");
                //$("item", data).each(function (i, domEle) {
                //$(".ajax.ajaxResult").append("<li>" + $(domEle).children("title").text() + "</li>");
                //});
                $("#divRequest").html(data);
                //$("#divGreet").load("/Friend/LoadMyGreet/");
                ShowDialogMessage('right', "您的操作成功了！");
            },
            error: function () {
                ShowDialogMessage('error', "您的操作失败了，请重试！");
            }
        }).done(function (msg) {

        });


    }
</script>
<h3>
    我的招呼<a>总共 @Model.Count() 个招呼</a></h3>
<div class="tr clearfix">
    <div class="friend_list">
        <ul class="clearfix">
            @foreach (var item in Model)
            {

                
                
                <li>
                    <div class="friend_item">
                        <div class="friend_pic">
                            <a  href="@Url.Action("View", "User", new { id = item.UserID })">
                                @if (item.GreetPhoto == "none_75_75.png")
                                {
                                    <img src="@Url.Content("~/Content/ad/none_75_75.png")" alt="头像" height="77px" width="77px"/>
                                }
                                else
                                {   <img src="@Url.Content("~/Files/Photos/" + item.UserID + "/Title/" + item.GreetPhoto)" alt="" />}
                            </a>
                            @if (item.Type == (int)DLM.Domain.Model.GreetType.Phone)
                            {
                                <div class="tips">
                                  向您所要联系方式：  @item.Message<span class="tra"></span></div>
                            }
                            else if (item.Type == (int)DLM.Domain.Model.GreetType.Normal)
                            { 
                                <div class="tips">
                                    @item.GreetAccount 给您一个普通招呼<span class="tra"></span></div>
                            }
                            else if (item.Type == (int)DLM.Domain.Model.GreetType.Friend)
                            {
                                <div class="tips">
                                     @item.GreetAccount 对您表达了好感<span class="tra"></span></div> 
                            }
                        </div>
                        <div class="friend_info">
                            <a href="">@item.GreetAccount</a></div>
                        <div class="friend_act">
                            <div class="friend_act_left">
                                <a href="@Url.Action("View", "User", new { id = item.UserID })">查看资料</a>
                            </div>
                            <div class="friend_act_right">
                      @*          @using (Ajax.BeginForm("Confirm", "Friend", new { id = item.SID }, new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "divRequest", OnSuccess = "onGreetSuccessed", OnFailure = "onGreetFalied" }))
                                {

                                    <input type="submit" value="知道了" class="btn" />
                                }*@

                                <a onclick="confirmGreet(@item.SID)">接受</a>
                            </div>
                        </div>
                    </div>
                </li>
               
                
            }
        </ul>
        <div class="paging">
        @Ajax.Pager(Model as PagedList<DLM.Domain.DTO.SalutationDTO>, new PagerOptions
   {
       PageIndexParameterName = "requestid",
       CurrentPagerItemWrapperFormatString = "<span class=\"current\">{0}</span>",
       //NumericPagerItemWrapperFormatString = "<a>{0}</a>",
       PrevPageText = "<",
       NextPageText = ">",
       ShowNumericPagerItems = true,
       ShowFirstLast = false,
       ShowPrevNext = true,
       CssClass = "scott",
       MorePageText = "...",
       SeparatorHtml = ""
   },
        new AjaxOptions { UpdateTargetId = "divRequest" }
    )
    </div>
    </div>
</div>
